import Vue from 'vue'
import Vuex from 'vuex'

import {getSkyList} from "@/api/search.js";
Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		skeyword: "", //记录用户搜索的关键词
		skyList: '' //记录用户关键词---推荐列表
	},
	mutations: {
		updateSkd(state,skeyword) {
			state.skeyword = skeyword
		},
		updateSkyList(state,skyList){
			// console.log(state,skyList);
			state.skyList = skyList;
		}
	},
	actions: {
		updateSkd(context,payload){
			// 修改仓库的值
			context.commit("updateSkd",payload)
			// ajax数据请求
			getSkyList(payload)
			.then((res)=>{
				// console.log(res.result.allMatch)
				context.commit("updateSkyList",res.result.allMatch)
			})
		}
	},
	modules: {
		
	}
})
